import {Component} from '@angular/core';
import {NzContentComponent, NzHeaderComponent, NzLayoutComponent, NzSiderComponent} from "ng-zorro-antd/layout";
import {NzMenuDirective, NzMenuItemComponent, NzSubMenuComponent} from "ng-zorro-antd/menu";
import {NzTooltipDirective} from "ng-zorro-antd/tooltip";
import {Router, RouterLink, RouterOutlet} from "@angular/router";
import {NzIconModule} from "ng-zorro-antd/icon";
import {UserService} from "../user/user.service";
import {NzMessageService} from "ng-zorro-antd/message";
import {NzCardComponent} from "ng-zorro-antd/card";

@Component({
  selector: 'app-home',
  standalone: true,
  imports: [
    NzLayoutComponent,
    NzSiderComponent,
    NzMenuDirective,
    NzMenuItemComponent,
    NzTooltipDirective,
    RouterLink,
    NzSubMenuComponent,
    NzHeaderComponent,
    NzContentComponent,
    RouterOutlet,
    NzIconModule,
    NzCardComponent
  ],
  templateUrl: './home.component.html',
  styleUrl: './home.component.css'
})
export class HomeComponent {

  isCollapsed: boolean = false;

  constructor(private userService: UserService,
              private messageService: NzMessageService,
              private router: Router) {
  }

  handleLogout() {
    this.userService.userLogout()
      .subscribe(res => {
        if (res) {
          this.messageService.success("登出成功");
          this.router.navigate(['/login'])
        }
      })
  }

}
